package vip.xiaonuo.sys.modular.setting.columnssetting.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.sys.modular.setting.columnssetting.entity.SysColumnsSetting;
import vip.xiaonuo.sys.modular.setting.columnssetting.param.SysColumnsSettingAddParam;
import vip.xiaonuo.sys.modular.setting.columnssetting.param.SysColumnsSettingEditParam;
import vip.xiaonuo.sys.modular.setting.columnssetting.param.SysColumnsSettingIdParam;
import vip.xiaonuo.sys.modular.setting.columnssetting.param.SysColumnsSettingPageParam;
import vip.xiaonuo.sys.modular.setting.columnssetting.service.SysColumnsSettingService;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 列设置表控制器
 *
 * @author Mr.wu
 * @date  2025/04/02 23:05
 */
@Tag(name = "列设置表控制器")
@RestController
@Validated
public class SysColumnsSettingController {

    @Resource
    private SysColumnsSettingService sysColumnsSettingService;

    /**
     * 获取列设置表分页
     *
     * @author Mr.wu
     * @date  2025/04/02 23:05
     */
    @Operation(summary = "获取列设置表分页")
    @SaCheckPermission("/sys/setting/columnssetting/page")
    @GetMapping("/sys/setting/columnssetting/page")
    public CommonResult<Page<SysColumnsSetting>> page(SysColumnsSettingPageParam sysColumnsSettingPageParam) {
        return CommonResult.data(sysColumnsSettingService.page(sysColumnsSettingPageParam));
    }

    /**
     * 添加列设置表
     *
     * @author Mr.wu
     * @date  2025/04/02 23:05
     */
    @Operation(summary = "添加列设置表")
    @CommonLog("添加列设置表")
    @SaCheckLogin
    @PostMapping("/sys/setting/columnssetting/add")
    public CommonResult<SysColumnsSetting> add(@RequestBody @Valid SysColumnsSettingAddParam sysColumnsSettingAddParam) {
        return CommonResult.data(sysColumnsSettingService.add(sysColumnsSettingAddParam));

    }

    /**
     * 编辑列设置表
     *
     * @author Mr.wu
     * @date  2025/04/02 23:05
     */
    @Operation(summary = "编辑列设置表")
    @CommonLog("编辑列设置表")
    @SaCheckLogin
    @PostMapping("/sys/setting/columnssetting/edit")
    public CommonResult<SysColumnsSetting> edit(@RequestBody @Valid SysColumnsSettingEditParam sysColumnsSettingEditParam) {
        return CommonResult.data(sysColumnsSettingService.edit(sysColumnsSettingEditParam));

    }

    /**
     * 删除列设置表
     *
     * @author Mr.wu
     * @date  2025/04/02 23:05
     */
    @Operation(summary = "删除列设置表")
    @SaCheckLogin
    @SaCheckPermission("/sys/setting/columnssetting/delete")
    @PostMapping("/sys/setting/columnssetting/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<SysColumnsSettingIdParam> sysColumnsSettingIdParamList) {
        sysColumnsSettingService.delete(sysColumnsSettingIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取列设置表详情
     *
     * @author Mr.wu
     * @date  2025/04/02 23:05
     */
    @Operation(summary = "获取列设置表详情")
    @SaCheckLogin
    @GetMapping("/sys/setting/columnssetting/detail")
    public CommonResult<SysColumnsSetting> detail(@Valid SysColumnsSetting sysColumnsSetting) {
        return CommonResult.data(sysColumnsSettingService.detail(sysColumnsSetting));
    }
}
